﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Eis51.CampanyCMS.Model.Bus;
using Eis51.CampanyCMS.Business.Bus;

namespace Eis51.Web.dataPage
{
    public partial class Product1 : System.Web.UI.Page
    {
        private int Pid;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }
            if (!Check())
            {
                return;
            }
            string returnStr = string.Empty;

            LoadData(ref returnStr);
        }

        private bool Check()
        {
            if (string.IsNullOrEmpty(Request.QueryString["type"])
            || string.IsNullOrEmpty(Request.QueryString["pid"]))
            {
                return false;
            }
            return true;
        }


        private void LoadData(ref string hoemData)
        {
            try
            {
                Pid = int.Parse(Request.QueryString["pid"]);
            }
            catch (Exception ex)
            {
                return;
            }
            switch (Request.QueryString["type"].ToLower())
            {
                case "product":
                    LoadProduct();
                    return;
            }
        }

        private void LoadProduct()
        {
            Products product = ProductsBLL.GetInstance().Get(new Products.Key(Pid));
            if (null != product)
            {
                divContent.InnerHtml = product.Descr;
            }
        }

    }
}
